import { DirectionType, MoveKeyType } from ".";
import { Tank } from "./tank";
import { Image } from "leafer-ui";

export class MyTank extends Tank {
  constructor(obj?: {
    direction?: DirectionType;
    speed: number;
    x?: number;
    y?: number;
    moveKey?: MoveKeyType;
    id?: string;
  }) {
    const {
      direction = "right",
      speed = 1,
      x = 0,
      y = 0,
      moveKey,
      id,
    } = obj || {};
    const myTank = new Image({
      url: "/mytank.png",
      width: 40,
      draggable: false,
      height: 40,
      x,
      y,
    });
    super({
      x,
      y,
      targter: myTank,
      speed,
      width: 50,
      height: 50,
      direction,
      id,
      moveKey: moveKey || {
        right: "KeyD",
        left: "KeyA",
        top: "KeyW",
        down: "KeyS",
        enter: "Enter",
      },
    });
  }
}
